package org.hcf.api;

import java.util.HashMap;
import java.util.Map;

public enum ErrorCode {
    SUCCESS(0, "操作成功"),
    SECRET_ERROR(1000, "安全验证失败"),
    USER_NOT_EXISTS(1001, "用户不存在"),
    PASSWORD_ERROR(1002, "密码验证错误"),
    PARAM_ERROR(1003, "参数错误"),
    USER_EXISTS(1004, "用户已存在"),
    CREATE_USER_ERROR(1005, "创建用户失败"),
    UPDATE_PWD_ERROR(1006, "修改密码失败"),
    REGISTER_CODE_ERROR(1007, "验证码错误"),
    HAS_REGISTER_CODE(1008, "验证码超时时间未到"),
    SAVE_AVATAR_ERROR(1009,"保存用户头像异常"),
    ;
    static Map<Integer, ErrorCode> map = new HashMap<>();

    static {
        for (ErrorCode value : values()) {
            map.put(value.NUM, value);
        }
    }

    public int NUM;
    public String DIC;

    ErrorCode(int num, String dic) {
        this.NUM = num;
        this.DIC = dic;
    }

    public static ErrorCode forNumber(int num) {
        return map.get(num);
    }
}
